<template>
  <view class="add_comment">
    <view class="title">
      {{topic}}
    </view>
    <view class="container">
      <u--textarea v-model="content" placeholder="分享你的想法" autoHeight border="none"></u--textarea>
    </view>
    <view class="commit">
      <button type="primary" @click="commit">发布</button>
    </view>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        topic: '前端框架',
        content: ``,
      };
    },
    computed: {
      nowTime() {
        const time = new Date()
        return time.getFullYear() + '年' + (time.getMonth() + 1) + '月' + time.getDate() + '日'
      },
    },
    methods: {
      commit() {
        let data = {
          id: 5100,
          title: this.content,
          from:this.topic,
          like: 0,
          discuss_count: 0,
          context: "内容",
          time: this.nowTime
        }
        uni.$emit('commit', data)
        uni.navigateBack()
      }
    }
  }
</script>

<style lang="less">
  page {
    background-color: #fff;
  }

  .add_comment {
    .title {
      padding: 20rpx 20rpx;
      height: 80rpx;
      font-size: 48rpx;
      font-weight: 600;
    }

    .container {
      padding: 20rpx 20rpx;
      margin: 20rpx 10rpx;
      box-shadow: 0rpx 4rpx 4rpx 4rpx #cccccc;

      .u-textarea__field.data-v-09988a29 {
        color: #161616;
        font-weight: 500;
        font-size: 36rpx;
      }
    }

    .commit {
      padding: 20rpx 20rpx;

      button {
        margin-top: 20rpx;
        border-radius: 30rpx;
      }
    }

  }
</style>
